﻿using System;
using EntityObject;
using SharedLibraries;
using SharedLibraries.Constants;
using ThangNM_LIB.DB;
using ThangNM_LIB.FUNC;

namespace ThangNM.Admin
{
    public partial class MediaUI : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Title_FormUC1.setTitle(ConstEx.Table_Name_C.Media, ConstEx.funcButtonToolBar.LIST);
            MsgUC1.setClearMsg();
            if (!IsPostBack)
            {
                if ((new ShareDAO.UserDAO()).SelectBy_sPermission(Session["secret"], Convert.ToString(Request.Url.AbsolutePath), ConstEx.funcButtonToolBar.MAIN) == false)
                {
                    mtvMain.Visible = false;
                    Commons.setAccessDenied(Page, MsgUC1);
                    return;
                }
                //if (Request.QueryString[QueryString.iType] != null)
                //{
                if (Request.QueryString[QueryString.type] != null)
                {
                    Media_ListUC1.FK_iCategoryID = Convert.ToInt16(Request.QueryString[QueryString.type]);
                    Media_DetailUC1.FK_iCategoryID = Convert.ToInt16(Request.QueryString[QueryString.type]);
                }
                else
                {
                    Media_ListUC1.FK_iCategoryID = 1;
                    Media_DetailUC1.FK_iCategoryID = 1;
                }
                //Media_ListUC1.BindData_List(Media_DetailUC1.iType);
                //}
            }
        }

        //public override void VerifyRenderingInServerForm(Control control)
        //{
        //    /* Verifies that the control is rendered */
        //}

        #region "Raise Event"
        protected void ViewDetail_Click(object sender, CustomerEventArgs e)
        {
            mtvMain.SetActiveView(vDetail);
            Media_DetailUC1.BindDataDetail((MediaEO)e.objEntity, ConstEx.FunctionType.View);
            Title_FormUC1.setTitle(ConstEx.Table_Name_C.Media, ConstEx.funcButtonToolBar.DETAIL);
        }

        protected void Notification_Click(object sender, CustomerEventArgs e)
        {
            MsgUC1.setNotifications(ConstEx.FunctionSetMsg.INFO, e.sMessage);
        }

        protected void Insert_Click(object sender, EventArgs e)
        {
            mtvMain.SetActiveView(vDetail);
            MediaEO _MediaEO = new MediaEO();
            Media_DetailUC1.BindDataDetail(_MediaEO, ConstEx.FunctionType.Insert);
            Title_FormUC1.setTitle(ConstEx.Table_Name_C.Media, ConstEx.funcButtonToolBar.INSERT);
        }

        protected void ViewMessageList_Click(object sender, CustomerEventArgs e)
        {
            MsgUC1.setNotifications(e.iType, e.sMessage);
        }

        protected void ViewMessageDetail_Click(object sender, CustomerEventArgs e)
        {
            if (e.iType == ConstEx.FunctionSetMsg.SUCCESS)
            {
                mtvMain.SetActiveView(vList);
                Media_ListUC1.ResetFormSearch();
                Media_ListUC1.BindData_List(Convert.ToInt16(Request.QueryString[QueryString.type]), null);
            }
            MsgUC1.setNotifications(e.iType, e.sMessage);
        }

        protected void BackList_Click(object sender, EventArgs e)
        {
            mtvMain.SetActiveView(vList);
            Media_ListUC1.ResetFormSearch();
            Media_ListUC1.BindData_List(Convert.ToInt16(Request.QueryString[QueryString.type]), null);
            Title_FormUC1.setTitle(ConstEx.Table_Name_C.Media, ConstEx.funcButtonToolBar.LIST);
        }
        #endregion

        //#region "Raise Event"
        //protected void ViewDetail_Click(object sender, EventArgs e)
        //{
        //    MediaEO obj = new MediaEO();
        //    obj.PK_iMediaID = Media_ListUC1.PK_iMediaID;
        //    obj = MediaDAO.SelectItem(obj);
        //    mtvMain.SetActiveView(vDetail);
        //    Media_DetailUC1.BindData(obj);
        //    Media_DetailUC1.LoadDataByType(Media_DetailUC1.iType, ConstEx.FunctionType.View, 1);
        //    Title_FormUC1.setTitle(ConstEx.Table_Name_C.Media, MutilView_C.DETAIL);
        //}
        //protected void AddNew_Click(object sender, EventArgs e)
        //{
        //    //MediaEO obj = new MediaEO();
        //    mtvMain.SetActiveView(vDetail);
        //    Media_DetailUC1.LoadDataByType(Media_DetailUC1.iType, ConstEx.FunctionType.Insert, 1);
        //}

        //protected void Updated_Click(object sender, CustomerEventArgs e)
        //{
        //    mtvMain.SetActiveView(vList);
        //    Media_ListUC1.BindData(Media_DetailUC1.iType);
        //}
        //#endregion

        //protected void lbtnBack_Click(object sender, EventArgs e)
        //{
        //    mtvMain.SetActiveView(vList);
        //    Media_ListUC1.BindData(Media_DetailUC1.iType);
        //    Title_FormUC1.setTitle(ConstEx.Table_Name_C.Media, MutilView_C.LIST);
        //}
    }
}